/*  

Cafechess Library: Cover basic chess programming needs, like GUI, Engine integration, 
FEN and PGN parsing.

                 \\|//
                 (o o)
--------------ooO-(_)-Ooo----------------------------------
Copyright (C) 2009  By Gregory A. Prentice Snoqualmie, WA
                    www.cafechess.org
                    cafechess@comcast.net
                      Oooo
--------------oooO----(  )---------------------------------
              (  )    (_/
               \_)

Microsoft Public License (Ms-PL)
               
Revisions:

Author        Date    Description:

*/
using System;

namespace Cafechess.IO
{
	/// <summary>
	/// Summary description for FileRenamer.
	/// </summary>
	public class FileRenamer : DirectoryWalker
	{
    string coReplaceText;
    string coReplaceWith;
    public string ReplaceText
    {
      get{return coReplaceText;}
      set{coReplaceText = value;}
    }
    public string ReplaceWith
    {
      get{return coReplaceWith;}
      set{coReplaceWith = value;}

    }
		public FileRenamer() : base()
		{
      FoundFileEvent += new DirectoryWalker.FoundFile(RenameFile);
      ReplaceText = "";
      ReplaceWith = "";
		}
    private void RenameFile(string name)
    {
      string newname;
      if( name.IndexOf(ReplaceText) >= 0 )
      {
        newname = name.Replace(ReplaceText,ReplaceWith);
        System.IO.File.Move(name,newname);
      }
    }
	}
}
